#ifndef _ONEWIRE_h_
#define _ONEWIRE_h_


/*******************************************/

// #define ONEWIRE_SHORT_CIRCUIT  0x01
#define ONEWIRE_REAd_ROM	0x33
#define ONEWIRE_MATCH_ROM	0x55
#define ONEWIRE_SKIP_ROM	0xCC
#define	ONEWIRE_SEARCH_ROM	0xF0

#define	ONEWIRE_SEARCH_FIRST	0xFF		// start new search
#define	ONEWIRE_PRESENCE_ERR	0xFF
#define	ONEWIRE_DATA_ERR	    0xFE
#define ONEWIRE_LAST_DEVICE		0x00		// last device found
//			0x01 ... 0x40: continue searching

// rom-code size including CRC
#define ONEWIRE_ROMCODE_SIZE 8

unsigned char OneWire_Reset(void);

void OneWire_WriteBit(unsigned char bitval);
bit OneWire_ReadBit(void);
void OneWire_WriteByte(unsigned char val);
unsigned char OneWire_ReadByte(void);

unsigned char OneWire_RomSearch( unsigned char diff, unsigned char *id );

unsigned char OneWire_Command( unsigned char command, unsigned char *id );


void OneWire_SetBus(unsigned char pin);//,static volatile bit* IO_DIR);


#endif

